<?

/***************************************************************************
 Jupiter Content System @ Jupiterportal.com
 Copyright (C) 2005 Cosmin Flavius (highstrike@gmail.com)

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 More Info About The Licence At http://www.gnu.org/copyleft/gpl.html
****************************************************************************/

switch($a)
{
	//-----------------------------------------------------------------
	//  Loged admin actions
	//-----------------------------------------------------------------

	case 1:

		//-----------------------------------------------------------------
		//  Filter Acces Rightes
		//-----------------------------------------------------------------

		if(!isset($is_webmaster))
		{ header("location: $PHP_SELF?i=2"); exit; }

		//-----------------------------------------------------------------
		//  Navigation Stuff
		//-----------------------------------------------------------------

		$rows_per_page = $config['nav_log'];
		$numrows = $db->getInfo_countRows("log");

		$lastpage = ceil($numrows/$rows_per_page);
		$p = (int)$p;

		if ($p < 1) $p = 1;
		elseif ($p > $lastpage) $p = $lastpage;

		if($numrows != FALSE) $limit = 'LIMIT ' .($p - 1) * $rows_per_page .',' .$rows_per_page;
		else $limit = NULL;

		//-----------------------------------------------------------------
		//  Sorting Stuff
		//-----------------------------------------------------------------

		if(!isset($s)) $s = 'date'; // Default value
		if(!isset($t)) $t = 'DESC'; // Default value

		$sname1 = "date";
		$sname2 = "date";
		$sname3 = "user_user";
		$sname4 = "log";

		if($t == "ASC"){ $t = "DESC"; $t2 = "ASC"; }
		else{ $t = "ASC"; $t2 = "DESC"; }

		if($t == "ASC"){ $t3 = "<img src='templates/$template/images/misc/up.gif' border='0'>";}
		else{ $t3 = "<img src='templates/$template/images/misc/down.gif' border='0'>";}

		if($s == 1) $s = $sname1;
		if($s == 2) $s = $sname2;
		if($s == 3) $s = $sname3;
		if($s == 4) $s = $sname4;

		//-----------------------------------------------------------------
		//  Load log table
		//-----------------------------------------------------------------

		$logs = $db->getTable("SELECT user_id, user_user, date, log FROM log ORDER BY '$s' $t2 $limit");

		//-----------------------------------------------------------------
		//  Make a foreach to separate the results
		//-----------------------------------------------------------------

		if($logs != FALSE)
		{
			foreach($logs as $idx=>$log)
			{
				if($log['user_user'] == "Auto Protection") $log_user_user = $log['user_user'];
				else $log_user_user = "<a href='$PHP_SELF?n=modules/users&a=1&d={$log['user_id']}'>{$log['user_user']}</a>";

				//-----------------------------------------------------------------
				//  Make Layout
				//-----------------------------------------------------------------

				$layout .= "
					<tr class='".row2color($idx)."' onMouseOver=this.className='con3' onMouseOut=this.className='".row2color($idx)."' onclick=window.location.href='$PHP_SELF?n=modules/users&a=1&d={$log['user_id']}'>
					<td><img src='templates/$template/images/status/stat".arrow_legend($log['date']).".gif' border='0' alt='".arrow_legend($log['date'])."'></td>
					<td align='center'>".today_yesterday($log['date'])."</td>
					<td>$log_user_user</td>
					<td>{$log['log']}</td>
					</tr>\n";

				//-----------------------------------------------------------------
				//  Start from 1
				//-----------------------------------------------------------------

				$idx++;
			}
		}
		else
		{
			//-----------------------------------------------------------------
			//  Reset to 0
			//-----------------------------------------------------------------

			$idx = 0;

			//-----------------------------------------------------------------
			//  Make Layout
			//-----------------------------------------------------------------

			$layout .= "
				<tr class='con1'>
				<td colspan='5'>{$language['Loged Admin desc']}</td>
				</tr>\n";
		}

		//-----------------------------------------------------------------
		//  Navigation Code
		//-----------------------------------------------------------------

		if($p == 1) $nav_prev = "<tr><td class='con1' align='right'>&nbsp;</td>";
		else
		{
			$prevpage = $p-1;
			$nav_prev = "<tr><td class='con1' align='left'><a href='$PHP_SELF?n=modules/misc&a=1&s=$s&t=$t2&p=$prevpage'>&laquo; {$language['Loged Admin previous']}</a></td>";
		}

		$nav_nr = '[ '.paginate($lastpage, $p, $PHP_SELF.'?n=modules/misc&a=1&s='.$s.'&t='.$t2).' ]';

		if($idx == $numrows) $nav_nr = NULL;

		if($p == $lastpage)
			$nav_next = "<td class='con1' align='right'>&nbsp;</td></tr>";
		else
		{
			$nextcode = $numrows - $idx * $p;
			if($nextcode > $idx) $how_next = $idx;
			else $how_next = $nextcode;

			$nextpage = $p+1;

			$nav_next = "<td class='con1' align='right'><a href='$PHP_SELF?n=modules/misc&a=1&s=$s&t=$t2&p=$nextpage'>{$language['Loged Admin next']} $how_next &raquo;</a></td></tr>";
		}

		if($idx == $numrows)
		{
			$nav_head = "class='con1'";
			$nav = NULL;
		}
		else
		{
			$nav_head = "class='head'";
			$nav = ''.$nav_prev.''.$nav_next.'';
		}

		//-----------------------------------------------------------------
		// Echo the back link
		//-----------------------------------------------------------------

		echo "<table class='main' cellspacing='1' cellpadding='4'><tr class='head'><td colspan='3'>{$language['Admin name']}</td></tr><tr><td colspan='3' class='con1' onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href='$PHP_SELF?n=modules/admin'><a href='$PHP_SELF?n=modules/admin'> &raquo; {$language['Admin back']}</a></td></tr></table><br>";

		//-----------------------------------------------------------------
		//  Start Layout + Navigation
		//-----------------------------------------------------------------

		?>
			<table class="main" cellspacing="1" cellpadding="4">
			<tr class='head'><td colspan='5'><?= $language['Loged Admin title'] ?></td></tr>
			<tr class="bottom">
			<td width="1%" align="center"><a href="<?= $PHP_SELF ?>?n=modules/misc&a=1&s=1&t=<?= $t ?>&p=<?= $p ?>"><? if($s == $sname1) echo $t3; else echo "*" ?></a></td>
			<td width="15%"><a href="<?= $PHP_SELF ?>?n=modules/misc&a=1&s=2&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Loged Admin title2'] ?> <? if($s == $sname2) echo $t3 ?></a></td>
			<td width="15%"><a href="<?= $PHP_SELF ?>?n=modules/misc&a=1&s=3&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Loged Admin title3'] ?> <? if($s == $sname3) echo $t3 ?></a></td>
			<td width="69%"><a href="<?= $PHP_SELF ?>?n=modules/misc&a=1&s=4&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Loged Admin title4'] ?> <? if($s == $sname4) echo $t3 ?></a></td>
			</tr>
			<?= $layout ?>
			</table><br>
			<table class="main" cellspacing="1" cellpadding="4">
			<col width="50%"><col width="50%">
			<tr><td class="con1"><img src="templates/<?= $template ?>/images/status/stat1.gif" border="0"> <?= $language['Indicator1'] ?></td><td class="con1"><img src="templates/<?= $template ?>/images/status/stat3.gif" border="0"> <?= $language['Indicator3'] ?></td></tr>
			<tr><td class="con1"><img src="templates/<?= $template ?>/images/status/stat2.gif" border="0"> <?= $language['Indicator2'] ?></td><td class="con1"><img src="templates/<?= $template ?>/images/status/stat4.gif" border="0"> <?= $language['Indicator4'] ?></td></tr>
			</table>
			<br>
			<table class="main" cellspacing="1" cellpadding="4" width="100%">
			<col width="50%"><col width="50%">
			<tr <?= $nav_head ?>>
			<td colspan="2">
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
			<col width="50%"><col width="50%">
			<tr class="empty">
			<td align="left"><?= $language['Loged Admin nav'] ?> <b><?= $idx ?></b> <?= $language['Loged Admin nav2'] ?> <b><?= $numrows ?></b></td>
			<td align="right"><?= $nav_nr ?></td>
			</tr>
			</table>
			</td>
			</tr>
			<?= $nav ?>
			</table>
		<?

	break;

	//-----------------------------------------------------------------
	//  FAQ BBcode
	//-----------------------------------------------------------------

	case 2:

		?>
			<table class="main" cellspacing="1" cellpadding="4">
			<tr class='head'><td colspan='5'><?= $language['FAQ bbcode desc'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ bbcode desc2'] ?></td></tr>
			<tr class="con1"><td style="Text-align: justify"><?= $language['FAQ bbcode desc3'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ bbcode desc4'] ?></td></tr>
			<tr class="con1"><td style="Text-align: justify"><?= $language['FAQ bbcode desc5'] ?><?= $language['FAQ bbcode desc6'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ bbcode desc7'] ?></td></tr>
			<tr class="con1"><td style="Text-align: justify"><?= $language['FAQ bbcode desc8'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ bbcode desc9'] ?></td></tr>
			<tr class="con1"><td style="Text-align: justify"><?= $language['FAQ bbcode desc10'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ bbcode desc11'] ?></td></tr>
			<tr class="con1"><td style="Text-align: justify"><?= $language['FAQ bbcode desc12'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ bbcode desc13'] ?></td></tr>
			<tr class="con1"><td style="Text-align: justify"><?= $language['FAQ bbcode desc14'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ bbcode desc15'] ?></td></tr>
			<tr class="con1"><td style="Text-align: justify"><?= $language['FAQ bbcode desc16'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ bbcode desc17'] ?></td></tr>
			<tr class="con1"><td style="Text-align: justify"><?= $language['FAQ bbcode desc18'] ?><?= $language['FAQ bbcode desc19'] ?><?= $language['FAQ bbcode desc20'] ?></td></tr>
			</table>
		<?

	break;

	//-----------------------------------------------------------------
	//  FAQ Emoticons
	//-----------------------------------------------------------------

	case 3:

		?>
			<table class="main" cellspacing="1" cellpadding="4">
			<tr class='head'><td colspan='5'><?= $language['FAQ emoticons desc'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ emoticons desc2'] ?></td></tr>
			<tr class="con1"><td style="Text-align: justify"><?= $language['FAQ emoticons desc3'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ emoticons desc4'] ?></td></tr>
			<tr class="con1"><td><? foreach($emoticons_db as $idx=>$emoticon){ echo "<img src='images/emoticons/{$emoticon['pic']}' alt='{$emoticon['code']}'> [<b>{$emoticon['code']}</b>] "; } ?><br><br><?= $language['FAQ emoticons desc5'] ?></td></tr>
			</table>
		<?

	break;

	//-----------------------------------------------------------------
	//  FAQ Badwords
	//-----------------------------------------------------------------

	case 4:

		?>
			<table class="main" cellspacing="1" cellpadding="4">
			<tr class='head'><td colspan='5'><?= $language['FAQ badwords desc'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ badwords desc2'] ?></td></tr>
			<tr class="con1"><td style="Text-align: justify"><?= $language['FAQ badwords desc3'] ?></td></tr>
			<tr class="bottom"><td><?= $language['FAQ badwords desc4'] ?></td></tr>
			<tr class="con1"><td><?= $language['FAQ badwords desc5'] ?></td></tr>
			</table>
		<?

	break;

	//-----------------------------------------------------------------
	//  FAQ Search engine
	//-----------------------------------------------------------------

	case 5:

		?>
			<table class='main' cellspacing='1' cellpadding='4'>
			<col width="33%"><col width="67%">
			<tr class='head'><td colspan='2'><?= $language['FAQ search desc'] ?></td></tr>
			<tr class='bottom'><td colspan='2'><?= $language['FAQ search desc2'] ?></td></tr>
			<tr class='con1'><td colspan='2'><?= $language['FAQ search desc3'] ?></td></tr>
			<tr class='bottom'><td colspan='2'><?= $language['FAQ search desc4'] ?></td></tr>
			<tr valign='top' class='con1'><td><?= $language['FAQ search desc5'] ?></td><td><?= $language['FAQ search desc6'] ?></td></tr>
			<tr valign='top' class='con1'><td><?= $language['FAQ search desc7'] ?></td><td><?= $language['FAQ search desc8'] ?></td></tr>
			<tr valign='top' class='con1'><td><?= $language['FAQ search desc9'] ?></td><td><?= $language['FAQ search desc10'] ?></td></tr>
			<tr valign='top' class='con1'><td><?= $language['FAQ search desc11'] ?></td><td><?= $language['FAQ search desc12'] ?></td></tr>
			<tr valign='top' class='con1'><td><?= $language['FAQ search desc13'] ?></td><td><?= $language['FAQ search desc14'] ?></td></tr>
			<tr valign='top' class='con1'><td><?= $language['FAQ search desc15'] ?></td><td><?= $language['FAQ search desc16'] ?></td></tr>
			<tr valign='top' class='con1'><td><?= $language['FAQ search desc17'] ?></td><td><?= $language['FAQ search desc18'] ?></td></tr>
			</table>
		<?

	break;

	//-----------------------------------------------------------------
	//  Default case
	//-----------------------------------------------------------------

	default:

		header("location: $PHP_SELF?n=modules/misc&a=2");

	break;
}

?>